const { globalData, mfutil } = getApp();
import emitter from '../../utils/editorAnalysis/ev';
import onTapEvent from '../../utils/editorAnalysis/utils'
import getSystemInfoPage from "../../utils/editorAnalysis/phonemodel"
Page({
  data: {
    pageName: "page1",
    imgJson: null
  },
  onLoad() {
    
    // 页面加载
    //获取屏幕大小
    getSystemInfoPage();
  },
  onReady() {
    emitter.on('eventTop', onTapEvent);
    const swiper = mfutil.tempConfig.getCompByName('swiper');
    console.log(swiper)
    swiper.onSwiperChange(function (_index) {
      // console.log('当前下标=', _index)
    })
  },
  // 修改图片
  changeImgSrc() {
    const img = mfutil.tempConfig.getCompByName('img');
    img.setSrc('https://img.alicdn.com/imgextra/i4/1928865133/O1CN01Wq7qPt1nmxeFLY3h0_!!1928865133.jpg')
  },
  // 视频播放
  videoPlay() {
    const video = mfutil.tempConfig.getCompByName('video');
    video.play()
  },
  // 视频暂停
  videoPause() {
    const video = mfutil.tempConfig.getCompByName('video');
    video.pause()
  },

  swiperNext() {
    const swiper = mfutil.tempConfig.getCompByName('swiper');
    swiper.toNext()
  },
  swiperPrev() {
    const swiper = mfutil.tempConfig.getCompByName('swiper');
    swiper.toPrev()
  },
  swiperTo() {
    const swiper = mfutil.tempConfig.getCompByName('swiper');
    swiper.changeTo(1)
  },




  onShow() {
    // 页面显示
    // console.log(this)

    emitter.on('eventTop', onTapEvent);
  },
  onHide() {
    // 页面隐藏
    emitter.off("eventTop", onTapEvent)
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
});
